{{template "member/top.html" .}}
<div class="m-b-md"> <h3 class="m-b-none">{{msg . "commentSet"}}</h3></div>

<div class="row">
<div class="col-sm-8">
	<div id="formData">
		<section class="panel panel-default">
			<div class="panel-body">
  				<div class="alert alert-danger" id="baseMsg" style="display: none"></div>
  				<form class="form-horizontal" role="form">
					<div class="form-group">
						<div class="col-sm-12">
							<label>
								<input type="checkbox" id="CanComment" name="CanComment"
									{{if .userBlog.CanComment}}checked="checked"{{end}} > {{msg . "openComment"}}
							</label>
							
							<br />
							
							<div id="commentSet" {{if not .userBlog.CanComment}}style="display: none"{{end}}>
								<label>
									<input type="radio"
										name="commentType"
										value="default"
										{{if or (not .userBlog.CommentType) (eq .userBlog.CommentType "default")}}checked="checked"{{end}} > {{msg $ "defaultComment"}}
								</label>
									
								<label>
									<input type="radio" name="commentType" id="disqus"
										value="disqus"
										{{if eq .userBlog.CommentType "disqus"}}checked="checked"{{end}} > Disqus
								</label>
					
								<div id="disqusSet" {{if not (eq .userBlog.CommentType "disqus")}}style="display: none"{{end}}>
									<label for="DisqusId">Disqus Id</label> <input type="text"
										class="form-control" style="display: inline; width: 50%"
										id="DisqusId" name="DisqusId"
										value="{{if .userBlog.DisqusId}}{{.userBlog.DisqusId}}{{else}}leanote{{end}}">
									<br /> 
									{{msg . "disqusHelp"}}
									<a target="_blank" href="http://leanote.com/blog/view/52db8463e01c530ef8000001">{{msg . "needHelp"}}</a>
								</div>
							</div>
						</div>
					</div>
				</form>
				
			</div>
			<footer class="panel-footer text-right bg-light lter">
			    <button type="submit" id="baseBtn" class="btn btn-success">{{msg . "submit"}}</button>
			</footer>
		</section>
	</div>
</div>

</div>
{{template "member/footer.html" .}}
<script>
var urlPrefix = "{{.siteUrl}}";
$(function() {
	// 评论
	$("#baseBtn").click(function(e) {
		e.preventDefault();
		var data = {
			CanComment : $("#CanComment").is(":checked"),
			CommentType: $("input[name='commentType']:checked").val(),
			DisqusId : $("#DisqusId").val(),
		}	
		post("/member/blog/setUserBlogComment", data, function(ret) {
			showAlert("#baseMsg", "{{msg . "saveSuccess"}}", "success");
		}, this);
	});
	$("#CanComment").click(function() {
		if ($(this).is(":checked")) {
			$("#commentSet").show();
		} else {
			$("#commentSet").hide();
		}
	});
	
	$("input[name='commentType']").click(function() {
		if ($("input[name='commentType']:checked").val() == "disqus") {
			$("#disqusSet").show();
		} else {
			$("#disqusSet").hide();
		}
	});
});
</script>

{{template "member/end.html" .}}
